﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessObjects.BO_GetObjects;

public partial class Controls_NewsDetails : Admin_Controls_Base {
    protected void Page_Load(object sender, EventArgs e) {
        if(!IsPostBack) {
            LoadData();
            LoadDataReleaseNews();
        }
    }
    //load chi tiet tin
    public void LoadData() {
        try {
            if(string.IsNullOrEmpty(Request["article_id"])) {
                ObjDT = BO_portal_articles.SelectByCategory(1, 1, Convert.ToInt32(Request["category_id"]), "ARTICLES");
            } else
                ObjDT = BO_portal_articles.Search(GetArticleId());
            if(ObjDT.Rows.Count > 0) {
                title_ar.InnerHtml = ObjDT.Rows[0]["FULL_ARTICLE_TITLE"].ToString();
            }
            rptData.DataSource = ObjDT;
            rptData.DataBind();
        } catch(Exception) {
        }
    }
    //get article id
    public int GetArticleId() {
        return int.Parse(Request.QueryString["article_id"]);
    }
    //load tin lien quan
    public void LoadDataReleaseNews() {
        try {
            if(string.IsNullOrEmpty(Request["article_id"])) {
                ObjDT = BO_portal_articles.SelectByCategory(1, 9, Convert.ToInt32(Request["category_id"]), "ARTICLES");
            } else
            {
                ObjDT = BO_portal_articles.Search(GetArticleId());
            }
            if(ObjDT.Rows.Count > 0) {
                ObjDT.Rows.RemoveAt(0);
            }
            rptData1.DataSource = ObjDT;
            rptData1.DataBind();
        } catch(Exception) {
        }
    }
}